version: '{build}'
pull_requests:
  do_not_increment_build_number: true
branches:
  only:
  - master
skip_tags: true
skip_branch_with_pr: true
max_jobs: 1
image: Visual Studio 2017
configuration: Release
init:
- cmd: >-
    tzutil /s "Russian Standard Time"

    git config --global core.autocrlf input
assembly_info:
  patch: true
  file: '**\AssemblyInfo.*'
  assembly_version: '{version}'
  assembly_file_version: '{version}'
  assembly_informational_version: '{version}'
install:
- ps: >-
    $AssemblyFile = "$env:APPVEYOR_PROJECT_NAME\Properties\AssemblyInfo.cs"

    $RegularExpression = [regex] '^\[assembly: AssemblyFileVersion\(\"(\d*\.\d*\.\d*)\.\d*\"\)\]$'

    $FileContent = Get-Content $AssemblyFile

    foreach($content in $FileContent) {
      $match = [System.Text.RegularExpressions.Regex]::Match($content, $RegularExpression)
      if($match.Success) {
        $env:VERSION = $match.groups[1].value
        break;
      }
    }

    Update-AppveyorBuild -Version ("{0}.{1}" -f $env:VERSION, $env:APPVEYOR_BUILD_NUMBER)

    $CommitDateTime = [datetime]::Parse($env:APPVEYOR_REPO_COMMIT_TIMESTAMP)

    $env:UPDATE = $CommitDateTime.ToString('yyyy-MM-dd')

    $env:UPD = $CommitDateTime.ToString('yyMMdd')

    $env:PACKAGE = ("{0}-v{1}-{2}b{3}" -f $env:APPVEYOR_PROJECT_NAME, $env:VERSION, $env:UPD, $env:APPVEYOR_BUILD_NUMBER)

    Write-Host "Building v$env:VERSION build $env:APPVEYOR_BUILD_NUMBER dated $env:UPDATE"
build:
  verbosity: minimal
before_package:
- cmd: >-
    copy %APPVEYOR_PROJECT_NAME%\bin\%CONFIGURATION%\%APPVEYOR_PROJECT_NAME%.exe*

    echo %APPVEYOR_PROJECT_NAME%.exe >>Package

    echo %APPVEYOR_PROJECT_NAME%.exe.config >>Package

    echo README.md >>Package

    copy %APPVEYOR_PROJECT_NAME%\*.xslt

    echo UFEBS.xslt >>Package

    echo %APPVEYOR_PROJECT_NAME% v%VERSION% build %APPVEYOR_BUILD_NUMBER% (%UPDATE%) >readme.txt

    echo http://%APPVEYOR_ACCOUNT_NAME%.github.io/%APPVEYOR_PROJECT_NAME% >>readme.txt
after_build:
- cmd: 7z a %PACKAGE%.zip @Package readme.txt
artifacts:
- path: $(package).zip
  name: AppZip
deploy:
- provider: GitHub
  tag: v$(version)
  release: $(appveyor_project_name) v$(version) build $(appveyor_build_number)
  description: '* $(appveyor_repo_commit_message) ($(update))\n\nAutomatic build $(appveyor_build_number) by AppVeyor\nSee docs on http://$(appveyor_account_name).github.io/$(appveyor_project_name)/'
  auth_token:
    secure: CePfctnBFd3iDwgVWlGOD6mfxQZrNBHK7IpsCK/deo2vHxA3lTr2nRnhbqpKqchQ
  artifact: AppZip
  draft: false
  prerelease: true
  force_update: true
  on:
    branch: master

only_commits:
  files:
    - ListXML\
    - appveyor.yml
